package com.ruoyi.develop.process.processPleaseBuy.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import com.ruoyi.develop.process.processPleaseBuy.mapper.ProcessPleaseBuyMapper;
import com.ruoyi.develop.process.processPleaseBuy.domain.ProcessPleaseBuy;
import com.ruoyi.develop.process.processPleaseBuy.service.IProcessPleaseBuyService;

/**
 * 请购单操作记录Service业务层处理
 *
 * @author lmm
 * @date 2025-06-10
 */
@Service
public class ProcessPleaseBuyServiceImpl implements IProcessPleaseBuyService {
    @Resource
    private ProcessPleaseBuyMapper processPleaseBuyMapper;

    /**
     * 查询请购单操作记录
     *
     * @param id 请购单操作记录主键
     * @return 请购单操作记录
     */
    @Override
    public ProcessPleaseBuy selectById(String id) {
        return processPleaseBuyMapper.selectById(id);
    }

    /**
     * 查询请购单操作记录列表
     *
     * @param entity 请购单操作记录
     * @return 请购单操作记录
     */
    @Override
    public List<ProcessPleaseBuy> selectList(ProcessPleaseBuy entity) {
        return processPleaseBuyMapper.selectList(entity);
    }

    /**
     * 新增请购单操作记录
     *
     * @param entity 请购单操作记录
     * @return 结果
     */
    @Override
    public int insert(ProcessPleaseBuy entity) {
        if (StringUtils.isBlank(entity.getId())) {
            entity.setId(IdUtils.fastSimpleUUID());
        }
        entity.setCreateBy(SecurityUtils.getUsername());
        entity.setCreateTime(DateUtils.getNowDate());
        return processPleaseBuyMapper.insert(entity);
    }

    /**
     * 修改请购单操作记录
     *
     * @param entity 请购单操作记录
     * @return 结果
     */
    @Override
    public int update(ProcessPleaseBuy entity) {
        entity.setUpdateBy(SecurityUtils.getUsername());
        entity.setUpdateTime(DateUtils.getNowDate());
        return processPleaseBuyMapper.update(entity);
    }

    /**
     * 批量删除请购单操作记录
     *
     * @param ids 需要删除的请购单操作记录主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return processPleaseBuyMapper.deleteByIds(ids);
    }

    /**
     * 删除请购单操作记录信息
     *
     * @param id 请购单操作记录主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return processPleaseBuyMapper.deleteById(id);
    }

    @Override
    public void insertPleaseBuyProcess(String pleaseBuyId, String type, String desc) {
        ProcessPleaseBuy processPleaseBuy = new ProcessPleaseBuy();
        processPleaseBuy.setId(IdUtils.fastSimpleUUID());
        processPleaseBuy.setPleaseBuyId(pleaseBuyId);
        processPleaseBuy.setType(type);
        processPleaseBuy.setOperDesc(desc);
        processPleaseBuy.setOperTime(new Date());
        processPleaseBuy.setOperBy(SecurityUtils.getUsername());
        processPleaseBuyMapper.insert(processPleaseBuy);
    }


}
